
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <title>context · React源码解析</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.0">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-api/theme-api.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

         
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="hydrate.html" />
    
    

<script
  async
  src="https://www.googletagmanager.com/gtag/js?id=UA-49483742-5"
></script>
<script>
  window.dataLayer = window.dataLayer || []
  function gtag() {
    dataLayer.push(arguments)
  }
  gtag('js', new Date())

  gtag('config', 'UA-49483742-5')
</script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    基础
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../api/react.html">
            
                <a href="../api/react.html">
            
                    
                    React API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../api/react-element.html">
            
                <a href="../api/react-element.html">
            
                    
                    ReactElement
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../api/react-children.html">
            
                <a href="../api/react-children.html">
            
                    
                    React Children
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../api/react-structure.html">
            
                <a href="../api/react-structure.html">
            
                    
                    React 中的数据结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    创建更新
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../update/react-dom-render.html">
            
                <a href="../update/react-dom-render.html">
            
                    
                    ReactDOM.render
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../update/set-state.html">
            
                <a href="../update/set-state.html">
            
                    
                    setState & forceUpdate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../update/expiration-time.html">
            
                <a href="../update/expiration-time.html">
            
                    
                    expirationTime 计算
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    任务调度
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../flow/scheduler-global.html">
            
                <a href="../flow/scheduler-global.html">
            
                    
                    全局变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../flow/schedule-work.html">
            
                <a href="../flow/schedule-work.html">
            
                    
                    scheduleWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../flow/scheduler-pkg.html">
            
                <a href="../flow/scheduler-pkg.html">
            
                    
                    react-scheduler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../flow/perform-work.html">
            
                <a href="../flow/perform-work.html">
            
                    
                    performWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../flow/perform-unit-of-work.html">
            
                <a href="../flow/perform-unit-of-work.html">
            
                    
                    performUnitOfWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../flow/render-root.html">
            
                <a href="../flow/render-root.html">
            
                    
                    renderRoot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.6.1" data-path="../flow/render-root/throw-exception.html">
            
                <a href="../flow/render-root/throw-exception.html">
            
                    
                    throwException
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../flow/begin-work.html">
            
                <a href="../flow/begin-work.html">
            
                    
                    beginWork
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.7.1" data-path="../flow/begin-work/mount-indeterminate-component.html">
            
                <a href="../flow/begin-work/mount-indeterminate-component.html">
            
                    
                    mountIndeterminateComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.2" data-path="../flow/begin-work/mount-lazy-component.html">
            
                <a href="../flow/begin-work/mount-lazy-component.html">
            
                    
                    mountLazyComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.3" data-path="../flow/begin-work/update-functional-component.html">
            
                <a href="../flow/begin-work/update-functional-component.html">
            
                    
                    updateFunctionalComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.4" data-path="../flow/begin-work/update-class-component.html">
            
                <a href="../flow/begin-work/update-class-component.html">
            
                    
                    updateClassComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.5" data-path="../flow/begin-work/update-host-root.html">
            
                <a href="../flow/begin-work/update-host-root.html">
            
                    
                    updateHostRoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.6" data-path="../flow/begin-work/update-host-component.html">
            
                <a href="../flow/begin-work/update-host-component.html">
            
                    
                    updateHostComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.7" data-path="../flow/begin-work/update-host-text.html">
            
                <a href="../flow/begin-work/update-host-text.html">
            
                    
                    updateHostText
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.8" data-path="../feature/Suspense-component.md">
            
                <span>
            
                    
                    updateSuspenseComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.9" data-path="../flow/begin-work/update-portal-component.html">
            
                <a href="../flow/begin-work/update-portal-component.html">
            
                    
                    updatePortalComponent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.10" data-path="../flow/begin-work/update-forward-ref.html">
            
                <a href="../flow/begin-work/update-forward-ref.html">
            
                    
                    updateForwardRef
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.11" data-path="../flow/begin-work/update-fragment.html">
            
                <a href="../flow/begin-work/update-fragment.html">
            
                    
                    updateFragment
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.12" data-path="../flow/begin-work/update-mode.html">
            
                <a href="../flow/begin-work/update-mode.html">
            
                    
                    updateMode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.13" data-path="../flow/begin-work/update-profiler.html">
            
                <a href="../flow/begin-work/update-profiler.html">
            
                    
                    updateProfiler
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.14" data-path="../flow/begin-work/update-context-provider.html">
            
                <a href="../flow/begin-work/update-context-provider.html">
            
                    
                    updateContextProvider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7.15" data-path="../flow/begin-work/update-context-consumer.html">
            
                <a href="../flow/begin-work/update-context-consumer.html">
            
                    
                    updateContextConsumer
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../flow/reconcile-children.html">
            
                <a href="../flow/reconcile-children.html">
            
                    
                    reconcileChildren
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.8.1" data-path="../flow/reconcile-children/single.html">
            
                <a href="../flow/reconcile-children/single.html">
            
                    
                    调和单个节点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8.2" data-path="../flow/reconcile-children/array.html">
            
                <a href="../flow/reconcile-children/array.html">
            
                    
                    调和列表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    commit 阶段
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../commit-phase/commit-root.html">
            
                <a href="../commit-phase/commit-root.html">
            
                    
                    commitRoot
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../commit-phase/invokeGuardedCallback.html">
            
                <a href="../commit-phase/invokeGuardedCallback.html">
            
                    
                    invokeGuardedCallback
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../commit-phase/commitBeforeMutationLifecycles.html">
            
                <a href="../commit-phase/commitBeforeMutationLifecycles.html">
            
                    
                    commitBeforeMutationLifecycles
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../commit-phase/commit-all-host-effects.html">
            
                <a href="../commit-phase/commit-all-host-effects.html">
            
                    
                    commitAllHostEffects
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.4.1" data-path="../commit-phase/host-effects/CommitPlacement.html">
            
                <a href="../commit-phase/host-effects/CommitPlacement.html">
            
                    
                    commitPlacement
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4.2" data-path="../commit-phase/host-effects/CommitWork.html">
            
                <a href="../commit-phase/host-effects/CommitWork.html">
            
                    
                    commitWork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4.3" data-path="../commit-phase/host-effects/CommitDeletion.html">
            
                <a href="../commit-phase/host-effects/CommitDeletion.html">
            
                    
                    commitDeletion
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../commit-phase/commit-all-lifecycles.html">
            
                <a href="../commit-phase/commit-all-lifecycles.html">
            
                    
                    commitAllLifecycle
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    功能
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.6.1" data-path="context.html">
            
                <a href="context.html">
            
                    
                    context
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="hydrate.html">
            
                <a href="hydrate.html">
            
                    
                    hydrate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="ref.html">
            
                <a href="ref.html">
            
                    
                    ref
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="event-injection.html">
            
                <a href="event-injection.html">
            
                    
                    事件系统初始化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="event-bind.html">
            
                <a href="event-bind.html">
            
                    
                    事件绑定
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="event-dispatch.html">
            
                <a href="event-dispatch.html">
            
                    
                    事件触发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="event-create-event-object.html">
            
                <a href="event-create-event-object.html">
            
                    
                    事件对象生成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="Suspense-component.html">
            
                <a href="Suspense-component.html">
            
                    
                    Suspense
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="suspense.html">
            
                <a href="suspense.html">
            
                    
                    挂起任务的含义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="suspense-lazy.html">
            
                <a href="suspense-lazy.html">
            
                    
                    lazy 组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" >
            
                <span>
            
                    
                    Hooks
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../hooks/hooks-start.html">
            
                <a href="../hooks/hooks-start.html">
            
                    
                    开始
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../hooks/hooks-use-state.html">
            
                <a href="../hooks/hooks-use-state.html">
            
                    
                    useState
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../hooks/hooks-use-effect.html">
            
                <a href="../hooks/hooks-use-effect.html">
            
                    
                    useEffect
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../hooks/hooks-others.html">
            
                <a href="../hooks/hooks-others.html">
            
                    
                    其他API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../hooks/hooks-common.html">
            
                <a href="../hooks/hooks-common.html">
            
                    
                    通用API
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <form
            action="https://buttondown.email/api/emails/embed-subscribe/Jokcy"
            method="post"
            target="popupwindow"
            onsubmit="window.open('https://buttondown.email/Jokcy', 'popupwindow')"
            class="buttondown-form"
            >
            <input type="email" name="email" id="bd-email" placeholder="(your@email.com)">
            <input type="hidden" value="1" name="embed"/>
            <button type="submit">订阅我</button>
        </form>
    </li>
</ul>

                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                 
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >context</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="stack">Stack</h1><p>&#x5728; React &#x7684;&#x66F4;&#x65B0;&#x8FC7;&#x7A0B;&#x4E2D;&#x6709;&#x4E00;&#x4E2A;<code>Stack</code>&#x6A21;&#x5757;&#xFF0C;&#x5728;&#x904D;&#x5386;&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x4F1A;&#x626E;&#x6F14;&#x5B58;&#x50A8;&#x4E0A;&#x4E0B;&#x6587;&#x7684;&#x4E00;&#x4E2A;&#x89D2;&#x8272;&#xFF0C;&#x4ED6;&#x4F1A;&#x5B58;&#x50A8;&#x5F88;&#x591A;&#x4FE1;&#x606F;&#xFF0C;&#x8BA9;&#x6211;&#x4EEC;&#x6765;&#x4E00;&#x4E00;&#x5206;&#x89E3;&#x8BB2;&#x89E3;&#x3002;</p><p>&#x9996;&#x5148;&#x6211;&#x4EEC;&#x6765;&#x8BB2;&#x4E00;&#x4E0B;<code>Stack</code>&#x7684;&#x6784;&#x6210;</p><pre><code class="lang-js"><span class="hljs-keyword">const</span> valueStack: <span class="hljs-built_in">Array</span>&lt;any&gt; = []

<span class="hljs-keyword">let</span> index = <span class="hljs-number">-1</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createCursor</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">defaultValue: T</span>): <span class="hljs-title">StackCursor</span>&lt;<span class="hljs-title">T</span>&gt; </span>{
  <span class="hljs-keyword">return</span> {
    current: defaultValue,
  }
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isEmpty</span>(<span class="hljs-params"></span>): <span class="hljs-title">boolean</span> </span>{
  <span class="hljs-keyword">return</span> index === <span class="hljs-number">-1</span>
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pop</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">cursor: StackCursor&lt;T&gt;, fiber: Fiber</span>): <span class="hljs-title">void</span> </span>{
  <span class="hljs-keyword">if</span> (index &lt; <span class="hljs-number">0</span>) {
    <span class="hljs-keyword">return</span>
  }

  cursor.current = valueStack[index]

  valueStack[index] = <span class="hljs-literal">null</span>

  index--
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">push</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">cursor: StackCursor&lt;T&gt;, value: T, fiber: Fiber</span>): <span class="hljs-title">void</span> </span>{
  index++

  valueStack[index] = cursor.current

  cursor.current = value
}</code></pre>
<p>&#x7CBE;&#x7B80;&#x4E4B;&#x540E;&#x7684;&#x6838;&#x5FC3;&#x6A21;&#x5757;&#x4EE3;&#x7801;&#x5982;&#x4E0A;&#xFF0C;&#x6240;&#x6709;&#x5185;&#x5BB9;&#x4F1A;&#x5B58;&#x50A8;&#x5728;<code>valueStack</code>&#x8FD9;&#x4E2A;&#x6570;&#x7EC4;&#x4E0A;&#xFF0C;&#x603B;&#x4F53;&#x7684;&#x64CD;&#x4F5C;&#x90FD;&#x975E;&#x5E38;&#x7B80;&#x5355;&#xFF0C;&#x6211;&#x76F8;&#x4FE1;&#x5927;&#x5BB6;&#x554A;&#x90FD;&#x80FD;&#x770B;&#x5F97;&#x61C2;&#x3002;</p><p>&#x800C;&#x5728;&#x8FD9;&#x4E2A;&#x552F;&#x4E00;&#x7684;&#x6570;&#x7EC4;&#x4E0A;&#x8981;&#x5B58;&#x50A8;&#x4EE5;&#x4E0B;&#x4E0D;&#x600E;&#x4E48;&#x76F8;&#x5173;&#x7684;&#x6570;&#x636E;&#xFF1A;</p><ul><li><code>childContext</code>
</li>
<li><code>NewContext</code>
</li>
<li><code>HostContext</code>
</li>
<li><code>HostContainer</code>
</li></ul>
<p>&#x4E3A;&#x4E86;&#x80FD;&#x591F;&#x5728;&#x540C;&#x4E00;&#x4E2A;&#x6808;&#x4E2D;&#x533A;&#x5206;&#x4E0D;&#x540C;&#x7684;&#x529F;&#x80FD;&#xFF0C;React &#x8BBE;&#x8BA1;&#x4E86;&#x4E00;&#x4E2A;<code>StackCursor</code>&#x7C7B;&#x578B;&#xFF0C;&#x7528;&#x6765;&#x533A;&#x5206;&#x4E0D;&#x540C;&#x7684;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x7684;&#x5F53;&#x524D;&#x503C;&#x3002;&#x5BF9;&#x4E8E;<code>cursor</code>&#x7684;&#x64CD;&#x4F5C;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x5165;&#x6808;&#x7684;&#x65F6;&#x5019;&#x8BBE;&#x7F6E;<code>cursor.current</code>&#x4E3A;&#x65B0;&#x7684;&#x503C;&#xFF0C;&#x51FA;&#x6808;&#x7684;&#x65F6;&#x5019;&#x8BBE;&#x7F6E;<code>cursor.current</code>&#x4E3A;&#x4E0A;&#x4E00;&#x4E2A;&#x503C;</p><p>&#x4F46;&#x662F;&#x8FD9;&#x91CC;&#x8FD8;&#x5B58;&#x5728;&#x4E00;&#x4E2A;&#x95EE;&#x9898;&#xFF0C;&#x90A3;&#x5C31;&#x662F;&#x6570;&#x636E;&#x5165;&#x6808;&#x7684;&#x987A;&#x5E8F;&#xFF0C;&#x5982;&#x679C;&#x5165;&#x6808;&#x4F4D;&#x7F6E;&#x51FA;&#x6808;&#x7684;&#x65F6;&#x5019;&#x7528;&#x7684;<code>cursor</code>&#x4E0D;&#x540C;&#xFF0C;&#x5C31;&#x4F1A;&#x5BFC;&#x81F4;&#x6570;&#x636E;&#x9519;&#x4E71;&#x3002;React &#x4E2D;&#x9632;&#x6B62;&#x51FA;&#x73B0;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x662F;&#x901A;&#x8FC7;<strong>&#x6BCF;&#x4E2A;&#x8282;&#x70B9;&#x5728; beginWork &#x7684;&#x65F6;&#x5019;&#x5165;&#x6808;&#xFF0C;&#x5728; completeUnitOfWork &#x7684;&#x65F6;&#x5019;&#x51FA;&#x6808;&#xFF0C;&#x4E25;&#x683C;&#x6309;&#x7167;&#x904D;&#x5386;&#x6811;&#x7684;&#x987A;&#x5E8F;</strong></p><h1 id="childcontext">childContext</h1><p><code>childContext</code>&#x662F; React &#x7684;&#x9057;&#x7559; API&#xFF0C;&#x5728; 17 &#x7248;&#x672C;&#x4E2D;&#x4F1A;&#x88AB;&#x79FB;&#x9664;&#xFF0C;&#x8BE5; API &#x5BF9;&#x4E8E; React &#x6E32;&#x67D3;&#x7684;&#x6548;&#x7387;&#x5F71;&#x54CD;&#x5F88;&#x5927;&#xFF0C;&#x4E0D;&#x63A8;&#x8350;&#x7EE7;&#x7EED;&#x4F7F;&#x7528;&#x3002;&#x76EE;&#x524D; React &#x6E90;&#x7801;&#x4E2D;&#x8C03;&#x7528;&#x8BE5; API &#x76F8;&#x5173;&#x7684;&#x65B9;&#x6CD5;&#x4F1A;&#x52A0;&#x4E0A;<code>Legacy</code>&#x5B57;&#x6837;&#x3002;</p><pre><code class="lang-js"><span class="hljs-keyword">let</span> contextStackCursor: StackCursor&lt;<span class="hljs-built_in">Object</span>&gt; = createCursor(emptyContextObject)
<span class="hljs-keyword">let</span> didPerformWorkStackCursor: StackCursor&lt;boolean&gt; = createCursor(<span class="hljs-literal">false</span>)</code></pre>
<p>&#x8FD9;&#x91CC;&#x5B58;&#x5728;&#x4E09;&#x4E2A;<code>cursor</code></p><h3 id="contextstackcursor">contextStackCursor</h3><p>&#x8BB0;&#x5F55;&#x5F53;&#x524D;&#x7EC4;&#x4EF6;&#x548C;&#x4ED6;&#x7684;&#x7236;&#x6811;&#x4E00;&#x8D77;&#x63D0;&#x4F9B;&#x7ED9;&#x5B50;&#x6811;&#x7684;<code>childContext</code>&#x5BF9;&#x8C61;&#xFF0C;&#x521D;&#x59CB;&#x9ED8;&#x8BA4;&#x662F;<code>emptyContextObject {}</code>&#x3002;</p><p>&#x5BF9;<code>FiberRoot</code>&#x4F1A;&#x6267;&#x884C;&#x7B2C;&#x4E00;&#x6B21;<code>push</code>&#xFF0C;&#x9664;&#x975E;&#x81EA;&#x884C;&#x8C03;&#x7528;<code>renderSubtreeIntoContainer</code>&#xFF0C;&#x4E0D;&#x7136;<code>root</code>&#x7684;<code>context</code>&#x90FD;&#x662F;<code>{}</code>&#xFF0C;&#x9664;&#x4E86;&#x521D;&#x6B21;&#x6E32;&#x67D3;&#xFF0C;<code>push</code>&#x7684;&#x503C;&#x90FD;&#x662F;<code>false</code>&#xFF0C;&#x8868;&#x660E;&#x76EE;&#x524D;<code>context</code>&#x6CA1;&#x6709;&#x53D8;&#x5316;&#x3002;</p><pre><code class="lang-js"><span class="hljs-comment">// updateHostRoot&#x7684;&#x65F6;&#x5019;&#x4F1A;&#x8C03;&#x7528;</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pushTopLevelContextObject</span>(<span class="hljs-params">
  fiber: Fiber,
  context: Object,
  didChange: boolean,
</span>): <span class="hljs-title">void</span> </span>{
  push(contextStackCursor, context, fiber)
  push(didPerformWorkStackCursor, didChange, fiber)
}</code></pre>
<p>&#x4E4B;&#x540E;&#x53EA;&#x6709;<code>ClassComponent</code>&#x80FD;&#x591F;&#x63D0;&#x4F9B;<code>childContext</code>&#xFF0C;&#x5728;<code>updateClassComponent</code>&#x7684;&#x8FC7;&#x7A0B;&#x4E2D;&#x4F1A;&#x8C03;&#x7528;<code>pushContextProvider</code>&#x6765;&#x63A8;&#x5165;&#x65B0;&#x7684;&#x5B50;&#x6811;<code>context</code>&#x5BF9;&#x8C61;&#x3002;</p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pushContextProvider</span>(<span class="hljs-params">workInProgress: Fiber</span>): <span class="hljs-title">boolean</span> </span>{
  <span class="hljs-keyword">const</span> instance = workInProgress.stateNode
  <span class="hljs-keyword">const</span> memoizedMergedChildContext =
    (instance &amp;&amp; instance.__reactInternalMemoizedMergedChildContext) ||
    emptyContextObject

  previousContext = contextStackCursor.current
  push(contextStackCursor, memoizedMergedChildContext, workInProgress)
  push(
    didPerformWorkStackCursor,
    didPerformWorkStackCursor.current,
    workInProgress,
  )

  <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>
}</code></pre>
<p>&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8FD9;&#x91CC;&#x53EA;&#x662F;&#x4ECE;<code>instance.__reactInternalMemoizedMergedChildContext</code>&#x8BFB;&#x53D6;&#x5BF9;&#x8C61;&#xFF0C;&#x4F46;&#x662F;&#x5728;<code>updateClassComponent</code>&#x8C03;&#x7528;&#x8FD9;&#x4E2A;&#x65B9;&#x6CD5;&#x7684;&#x65F6;&#x5019;&#x5E76;&#x6CA1;&#x6709;&#x8BA1;&#x7B97;&#x51FA;&#x65B0;&#x7684;<code>state</code>&#xFF0C;&#x6240;&#x4EE5;&#x662F;&#x5426;&#x6709;&#x65B0;&#x7684;<code>context</code>&#x4E5F;&#x662F;&#x672A;&#x77E5;&#x3002;&#x6CE8;&#x610F;&#x8FD9;&#x91CC;&#x7ED9;&#x5168;&#x5C40;&#x53D8;&#x91CF;<code>previousContext</code>&#x8D4B;&#x503C;&#x4E86;<code>contextStackCursor.current</code>&#xFF0C;&#x6240;&#x4EE5;&#x4ED6;&#x662F;&#x5F53;&#x524D;&#x7EC4;&#x4EF6;&#x7684;&#x7236;&#x6811;&#x63D0;&#x4F9B;&#x7684;<code>context</code>&#x7684;&#x96C6;&#x5408;&#x3002;&#x5728;&#x540E;&#x7EED;<code>finishClassComponent</code>&#x7684;&#x65F6;&#x5019;&#x5982;&#x679C;<code>state</code>&#x6216;&#x8005;<code>props</code>&#x6709;&#x66F4;&#x65B0;&#xFF0C;&#x90A3;&#x4E48;&#x9700;&#x8981;&#x91CD;&#x65B0;&#x8BA1;&#x7B97;<code>context</code>&#xFF0C;&#x4F1A;&#x6267;&#x884C;<code>invalidateContextProvider</code></p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">invalidateContextProvider</span>(<span class="hljs-params">
  workInProgress: Fiber,
  type: any,
  didChange: boolean,
</span>): <span class="hljs-title">void</span> </span>{
  <span class="hljs-keyword">const</span> instance = workInProgress.stateNode

  <span class="hljs-keyword">if</span> (didChange) {
    <span class="hljs-keyword">const</span> mergedContext = processChildContext(
      workInProgress,
      type,
      previousContext,
    )
    instance.__reactInternalMemoizedMergedChildContext = mergedContext

    pop(didPerformWorkStackCursor, workInProgress)
    pop(contextStackCursor, workInProgress)
    push(contextStackCursor, mergedContext, workInProgress)
    push(didPerformWorkStackCursor, didChange, workInProgress)
  } <span class="hljs-keyword">else</span> {
    pop(didPerformWorkStackCursor, workInProgress)
    push(didPerformWorkStackCursor, didChange, workInProgress)
  }
}</code></pre>
<p><code>processChildContext</code>&#x4F1A;&#x8BA1;&#x7B97;&#x51FA;&#x65B0;&#x7684;<code>childContext</code>&#xFF0C;&#x7136;&#x540E;&#x8D4B;&#x503C;&#x7ED9;<code>__reactInternalMemoizedMergedChildContext</code>&#xFF0C;&#x5E76;&#x4E14;&#x4E4B;&#x524D;&#x5BF9;&#x4E8E;&#x5F53;&#x524D;&#x7EC4;&#x4EF6;&#x5DF2;&#x7ECF;<code>push</code>&#x8FC7;&#x4E00;&#x6B21;&#x4E86;&#xFF0C;&#x6240;&#x4EE5;&#x8FD9;&#x91CC;&#x8981;&#x5148;<code>pop</code>&#x518D;<code>push</code>&#xFF0C;&#x800C;&#x4E14;&#x4E24;&#x4E2A;<code>cursor</code>&#x7684;&#x987A;&#x5E8F;&#x8981;&#x8C03;&#x6362;&#x3002;&#x800C;&#x5982;&#x679C;&#x65B0;&#x8001;<code>context</code>&#x90FD;&#x6CA1;&#x6709;&#x53D8;&#x5316;&#xFF0C;&#x4F1A;&#x8BBE;&#x7F6E;<code>didPerformWorkStackCursor</code>&#x4E3A;<code>false</code>&#xFF0C;&#x53EF;&#x4EE5;&#x4F18;&#x5316;&#x5B50;&#x6811;&#xFF0C;&#x4E0D;&#x9700;&#x8981;&#x6267;&#x884C;&#x4E0D;&#x5FC5;&#x8981;&#x7684;&#x66F4;&#x65B0;&#x3002;<strong>&#x6CE8;&#x610F;&#x8FD9;&#x91CC;&#x7684;<code>didChange</code>&#x8DDF;<code>shouldComponentUpdate</code>&#x6709;&#x5173;&#xFF0C;&#x53E6;&#x5916;&#x9700;&#x8981;&#x6CE8;&#x610F;<code>PureComponent</code>&#x4E0D;&#x4F1A;&#x5224;&#x65AD;<code>context</code>&#x662F;&#x5426;&#x53D8;&#x5316;&#x3002;</strong></p><h3 id="didperformworkstackcursor">didPerformWorkStackCursor</h3><p>&#x8FD9;&#x4E2A;&#x5C31;&#x662F;&#x7528;&#x6765;&#x6807;&#x8BB0;&#x5B50;&#x6811;&#x7684;<code>context</code>&#x662F;&#x5426;&#x53D8;&#x5316;&#x7684;&#xFF0C;&#x5728;&#x4EE5;&#x4E0A;&#x7684;&#x4EE3;&#x7801;&#x4E2D;&#x5DF2;&#x7ECF;&#x5F88;&#x660E;&#x663E;&#x4E86;&#xFF0C;&#x6240;&#x4EE5;&#x5C31;&#x4E0D;&#x518D;&#x5206;&#x6790;&#x3002;</p><pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">hasContextChanged</span>(<span class="hljs-params"></span>): <span class="hljs-title">boolean</span> </span>{
  <span class="hljs-keyword">return</span> didPerformWorkStackCursor.current
}</code></pre>
<h1 id="newcontext">NewContext</h1><p>&#x8FD9;&#x4E2A;&#x662F;&#x65B0;&#x7684;<code>Context API</code>&#x3002;</p><pre><code class="lang-js"><span class="hljs-keyword">const</span> valueCursor: StackCursor&lt;mixed&gt; = createCursor(<span class="hljs-literal">null</span>)</code></pre>
<p>&#x76F8;&#x5BF9;&#x6765;&#x8BF4;&#x4ED6;&#x7684;&#x903B;&#x8F91;&#x4F1A;&#x7B80;&#x5355;&#x633A;&#x591A;&#xFF0C;<code>Provider</code>&#x5904;&#x7406;&#x5982;&#x4E0B;&#xFF1A;</p><pre><code class="lang-js"><span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">pushProvider</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">providerFiber: Fiber, nextValue: T</span>): <span class="hljs-title">void</span> </span>{
  <span class="hljs-keyword">const</span> context: ReactContext&lt;T&gt; = providerFiber.type._context
  <span class="hljs-keyword">if</span> (isPrimaryRenderer) {
    push(valueCursor, context._currentValue, providerFiber)
    context._currentValue = nextValue
  } <span class="hljs-keyword">else</span> {
    push(valueCursor, context._currentValue2, providerFiber)
    context._currentValue2 = nextValue
  }
}

<span class="hljs-keyword">export</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">popProvider</span>(<span class="hljs-params">providerFiber: Fiber</span>): <span class="hljs-title">void</span> </span>{
  <span class="hljs-keyword">const</span> currentValue = valueCursor.current
  pop(valueCursor, providerFiber)
  <span class="hljs-keyword">const</span> context: ReactContext&lt;any&gt; = providerFiber.type._context
  <span class="hljs-keyword">if</span> (isPrimaryRenderer) {
    context._currentValue = currentValue
  } <span class="hljs-keyword">else</span> {
    context._currentValue2 = currentValue
  }
}</code></pre>
<p>ReactDOM &#x4E2D;<code>isPrimaryRenderer</code>&#x4E3A;<code>true</code>&#xFF0C;&#x6CE8;&#x610F;&#x8FD9;&#x91CC;&#x8BBE;&#x7F6E;&#x4E86;<code>context._currentValue</code>&#xFF0C;&#x5728;&#x540E;&#x7EED;&#x8981;&#x7528;&#x5230;<code>context</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6BD4;&#x5982;&#x901A;&#x8FC7;<code>Consumer</code>&#x8BFB;&#x53D6;&#x503C;&#xFF0C;&#x90A3;&#x4E48;&#x53EA;&#x9700;&#x8981;&#x8BFB;&#x53D6;&#x8FD9;&#x4E2A;&#x503C;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p><p>&#x5728;<code>React16.6</code>&#x4E4B;&#x540E;&#x5462;&#x589E;&#x52A0;&#x4E86;<code>ClassComponent.contextType</code>&#x5FEB;&#x901F;&#x8BA2;&#x9605;&#x65B0; API &#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x8FD8;&#x6709;<code>hooks</code>&#x4E2D;<code>functionalComponent</code>&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>useContext</code>&#x8BA2;&#x9605;&#x65B0; API&#xFF0C;&#x6240;&#x4EE5;&#x5462;&#x8FD9;&#x91CC;&#x6709;&#x4E24;&#x4E2A;&#x65B9;&#x6CD5;&#x6765;&#x5904;&#x7406;&#x8FD9;&#x4E2A;&#x903B;&#x8F91;&#xFF1A;</p><ul><li><code>propagateContextChange</code>
</li>
<li><code>readContext</code>
</li></ul>
<p>&#x4EE3;&#x7801;&#x6709;&#x70B9;&#x957F;&#xFF0C;&#x7528;&#x4E2A; gist &#x6765;&#x65B9;&#x5427;</p><script src="https://gist.github.com/Jokcy/c6b0e36383dbfc0e0e254f2ffe416a6b.js"></script>



<p><code>propagateContextChange</code>&#x5728;<code>ContextProvider</code>&#x68C0;&#x6D4B;&#x5230;<code>context</code>&#x7684;&#x503C;&#x6709;&#x53D8;&#x5316;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x8C03;&#x7528;&#xFF0C;&#x4ED6;&#x4F1A;&#x904D;&#x5386;&#x4ED6;&#x7684;&#x5B50;&#x6811;&#xFF0C;&#x627E;&#x6709;<code>firstContextDependency</code>&#x5C5E;&#x6027;&#x7684;<code>fiber</code>&#xFF0C;&#x5E76;&#x68C0;&#x6D4B;&#x4ED6;&#x662F;&#x5426;&#x6709;&#x4EE5;&#x6765;&#x5F53;&#x524D;&#x7684;<code>ContextProvider</code>&#xFF0C;&#x5982;&#x679C;&#x6709;&#x7684;&#x8BDD;&#x4F1A;&#x5728;&#x8FD9;&#x4E2A;&#x7EC4;&#x4EF6;&#x4E0A;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x66F4;&#x65B0;&#xFF0C;&#x5E76;&#x4E14;&#x8FD9;&#x4E2A;&#x66F4;&#x65B0;&#x7684;<code>expirationTime</code>&#x662F;&#x5F53;&#x524D;&#x6B63;&#x5728;&#x6267;&#x884C;&#x7684;&#x66F4;&#x65B0;&#x7684;<code>expirationTime</code>&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5728;&#x8FD9;&#x4E2A;&#x6E32;&#x67D3;&#x5468;&#x671F;&#x80AF;&#x5B9A;&#x4F1A;&#x88AB;&#x6E32;&#x67D3;&#xFF0C;&#x56E0;&#x4E3A;&#x521B;&#x5EFA;&#x4E86;&#x66F4;&#x65B0;&#xFF0C;&#x6240;&#x4EE5;&#x80AF;&#x5B9A;&#x8981;&#x66F4;&#x65B0;<code>expirationTime</code>&#x540C;&#x65F6;&#x8FD8;&#x8981;&#x66F4;&#x65B0;&#x7236;&#x94FE;&#x4E0A;&#x7684;<code>childExpirationTime</code>&#x3002;</p><p>&#x90A3;&#x4E48;<code>firstContextDependency</code>&#x54EA;&#x91CC;&#x6765;&#x7684;&#x5462;&#xFF1F;&#x5C31;&#x662F;&#x5728;&#x7EC4;&#x4EF6;&#x5728;&#x8C03;&#x7528;<code>readContext</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x76EE;&#x524D;&#x80FD;&#x770B;&#x7684;&#x6E90;&#x7801;&#xFF08;16.6&#xFF09;&#x8FD8;&#x6CA1;&#x6709;<code>hooks</code>&#x7684;&#x6E90;&#x7801;&#xFF0C;&#x6240;&#x4EE5;&#x76EE;&#x524D;&#x80FD;&#x770B;&#x5230;&#x7684;&#x662F;<code>ClassCompnent.contextType</code>&#xFF0C;&#x5BF9;&#x4E8E;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4ED6;&#x7684;&#x4F9D;&#x8D56;&#x53EA;&#x4F1A;&#x6709;&#x4E00;&#x4E2A;&#xFF0C;&#x800C;<code>hooks</code>&#x662F;&#x53EF;&#x4EE5;&#x8BFB;&#x53D6;&#x591A;&#x4E2A;&#x7684;&#x3002;</p><p><code>observedBits</code>&#x5728;&#x76EE;&#x524D;&#x7684;&#x6E90;&#x7801;&#x4E2D;&#x6CA1;&#x770B;&#x5230;&#x4EC0;&#x4E48;&#x4F5C;&#x7528;&#xFF0C;&#x867D;&#x7136;&#x6E90;&#x7801;&#x4E2D;<code>ContentConsumer</code>&#x4E2D;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>unstable_observedBits</code>&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#xFF0C;&#x4F46;&#x662F;&#x76EE;&#x524D;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x8BF4;&#x660E;&#x8FD9;&#x662F;&#x7528;&#x6765;&#x5E72;&#x561B;&#x7684;&#x3002;<em>&#x731C;&#x6D4B;&#x8DDF;<code>hooks</code>&#x6709;&#x5173;&#xFF1F;</em></p><h1 id="hostcontext--hostcontainer">HostContext &amp; HostContainer</h1><pre><code class="lang-js"><span class="hljs-keyword">let</span> contextStackCursor: StackCursor&lt;HostContext | NoContextT&gt; = createCursor(
  NO_CONTEXT,
)
<span class="hljs-keyword">let</span> contextFiberStackCursor: StackCursor&lt;Fiber | NoContextT&gt; = createCursor(
  NO_CONTEXT,
)
<span class="hljs-keyword">let</span> rootInstanceStackCursor: StackCursor&lt;Container | NoContextT&gt; = createCursor(
  NO_CONTEXT,
)</code></pre>
<p>&#x8FD9;&#x91CC;&#x4E3B;&#x7BA1;&#x7684;&#x5185;&#x5BB9;&#x6709;&#xFF1A;</p><h3 id="pushhostcontainer">pushHostContainer</h3><p>&#x5BF9;&#x4E8E;<code>HostRoot</code>&#x548C;<code>Proatl</code>&#x4ED6;&#x4EEC;&#x4F1A;&#x6709;&#x6302;&#x8F7D;&#x8282;&#x70B9;&#xFF0C;&#x6240;&#x4EE5;&#x4F1A;&#x6709;<code>container</code></p><h3 id="pushhostcontext">pushHostContext</h3><p>&#x8FD9;&#x4E2A;&#x662F;&#x7528;&#x6765;&#x5BF9;&#x539F;&#x751F;&#x8282;&#x70B9;&#x8FDB;&#x884C;&#x5165;&#x6808;&#x7684;&#x64CD;&#x4F5C;&#xFF0C;&#x4E3B;&#x8981;&#x8BB0;&#x5F55;&#x7684;&#x662F;<code>NameSpace</code></p><pre><code class="lang-js"><span class="hljs-keyword">const</span> HTML_NAMESPACE = <span class="hljs-string">&apos;http://www.w3.org/1999/xhtml&apos;</span>
<span class="hljs-keyword">const</span> MATH_NAMESPACE = <span class="hljs-string">&apos;http://www.w3.org/1998/Math/MathML&apos;</span>
<span class="hljs-keyword">const</span> SVG_NAMESPACE = <span class="hljs-string">&apos;http://www.w3.org/2000/svg&apos;</span>

<span class="hljs-keyword">switch</span> (type) {
  <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;svg&apos;</span>:
    <span class="hljs-keyword">return</span> SVG_NAMESPACE
  <span class="hljs-keyword">case</span> <span class="hljs-string">&apos;math&apos;</span>:
    <span class="hljs-keyword">return</span> MATH_NAMESPACE
  <span class="hljs-keyword">default</span>:
    <span class="hljs-keyword">return</span> HTML_NAMESPACE
}</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
<div id="disqus_thread"></div>
<script>
  /**
   *  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
   *  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
  /*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
  ;(function() {
    // DON'T EDIT BELOW THIS LINE
    var d = document,
      s = d.createElement('script')
    s.src = 'https://react-source-code.disqus.com/embed.js'
    s.setAttribute('data-timestamp', +new Date())
    ;(d.head || d.body).appendChild(s)
  })()
</script>
<noscript
  >Please enable JavaScript to view the
  <a href="https://disqus.com/?ref_noscript"
    >comments powered by Disqus.</a
  ></noscript
>

            </div>

            

        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"context","level":"1.6.1","depth":2,"next":{"title":"hydrate","level":"1.6.2","depth":2,"path":"book/features/hydrate.md","ref":"book/features/hydrate.md","articles":[]},"previous":{"title":"功能","level":"1.6","depth":1,"ref":"","articles":[{"title":"context","level":"1.6.1","depth":2,"path":"book/features/context.md","ref":"book/features/context.md","articles":[]},{"title":"hydrate","level":"1.6.2","depth":2,"path":"book/features/hydrate.md","ref":"book/features/hydrate.md","articles":[]},{"title":"ref","level":"1.6.3","depth":2,"path":"book/features/ref.md","ref":"book/features/ref.md","articles":[]},{"title":"事件系统初始化","level":"1.6.4","depth":2,"path":"book/features/event-injection.md","ref":"book/features/event-injection.md","articles":[]},{"title":"事件绑定","level":"1.6.5","depth":2,"path":"book/features/event-bind.md","ref":"book/features/event-bind.md","articles":[]},{"title":"事件触发","level":"1.6.6","depth":2,"path":"book/features/event-dispatch.md","ref":"book/features/event-dispatch.md","articles":[]},{"title":"事件对象生成","level":"1.6.7","depth":2,"path":"book/features/event-create-event-object.md","ref":"book/features/event-create-event-object.md","articles":[]},{"title":"Suspense","level":"1.6.8","depth":2,"path":"book/features/Suspense-component.md","ref":"book/features/Suspense-component.md","articles":[]},{"title":"挂起任务的含义","level":"1.6.9","depth":2,"path":"book/features/suspense.md","ref":"book/features/suspense.md","articles":[]},{"title":"lazy 组件","level":"1.6.10","depth":2,"path":"book/features/suspense-lazy.md","ref":"book/features/suspense-lazy.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["theme-api"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["weibo","google","twitter","weibo","instapaper"]},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-api":{"languages":[],"split":true,"theme":"light"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"React源码解析","language":"zh-hans","gitbook":"*"},"file":{"path":"book/features/context.md","mtime":"2019-01-07T03:56:29.824Z","type":"markdown"},"gitbook":{"version":"3.2.0","time":"2019-07-08T12:28:32.264Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-api/theme-api.js"></script>
        
    

    </body>
</html>

